package com.example.myspringboot.design.factory.ordinary.SimpleFactory;

import com.example.myspringboot.design.factory.dto.Product;
import com.example.myspringboot.design.factory.ordinary.impl.ConcreteproductA;
import com.example.myspringboot.design.factory.ordinary.impl.ConcreteproductB;

/**
 * @Author ZhengShan
 * @Date 2024 06 26 11 09
 **/
public class SimpleFactory {

    public static Product createProduct(String name){
        if("A".equals(name)){
            return new ConcreteproductA();
        }else if("B".equals(name)){
            return new ConcreteproductB();
        }else{
            throw new IllegalArgumentException("不支持的产品类型");
        }
    }
}
